
; 放在栈中

assume cs:code,ss:stack  ;,ds:data

stack segment
    dw 0,0,0,0,0,0,0,0
stack ends


code segment
start: 
    ; 初始化栈
    mov ax,stack
    mov ss,ax
    mov sp,16

    ; 计算1+...+100
    mov ax,0
    mov bx,1
    mov cx,100

l:  add ax,bx
    inc bx
    loop l

    ;mov ax,5050
    mov bx,17
    push bx ;标志位
    mov bx,10

p1:    
    mov dx,0
    div bx

    add dx,48
    push dx   ; 放进栈

    cmp ax,0
    jne p1

    ; 输出栈内内容
p2:
    pop bx
    cmp bl,17 ; 判断是否位结尾
    je p3


    mov ah,02h
    mov dl,bl
    int 21h

    jmp p2


p3:    mov ax,4c00h
    int 21h

code ends

end start